Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.x] Add assertInputPresent and assertInputMissing assertions #914

Merged
merged 2 commits into from
Aug 4, 2021
Merged

[6.x] Add assertInputPresent and assertInputMissing assertions #914

merged 2 commits into from
Aug 4, 2021

Conversation

SjorsO
Copy link
Contributor

@SjorsO SjorsO commented Aug 4, 2021

This PR adds two assertions: assertInputPresent and assertInputMissing. These assertions use the name of an input to assert if the input is present.

These assertions are useful when working with dynamic forms. I often use Livewire to hide input fields based on the value of a radio button. There is currently no convenient way to assert that an input with a specific name is missing. I'd have to add a dusk="" or id="" attribute to the input and then use assertMissing(). With these new assertions I can assert if an input is missing using its name, making extra attribute necessary.

Something to note: the name of the assertions might be slightly misleading. They don't just check input elements, but also textarea and select elements.

I haven't added any tests. I couldn't figure out how to craft a mock that calls itself. This probably wouldn't add much value to the test suite anyway. The new methods use the already tested assertPresent and assertMissing methods.

@taylorotwell taylorotwell merged commit 6112c8f into laravel:6.x Aug 4, 2021
taylorotwell pushed a commit to laravel/docs that referenced this pull request Aug 9, 2021
The `assertInputPresent` and `assertInputMissing` assertions were added in laravel/dusk#914
@SjorsO SjorsO mentioned this pull request Feb 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants